package WaiBao;

import java.util.Arrays;

public class HouZiYi {
    public static void main(String[] args) {
        String[] name = {"陈得蓉(班长)","吴大伟(体育委员)", "小李(学习委员)","陈松伶(文艺委员)", "陈小艺", "许美静", "杨恭如", "杨紫琼", "罗大佑", "罗中旭", "螺纹", "成小春",
                "徐小凤", "苏永康", "赵文瑄", "杨菜泥", "陈飞屏", "何赛飞", "合情", "陈金红", "何家劲", "何玲", "黄平原", "黄磊", "陈变强", "赵薇", "赵雅芝", "吴君如",
                "吴辰君", "侯兹尹(学生)"};//考生本人: 侯兹尹(学生)
        int[] age = {19,20,21,20, 18,21, 19, 20, 19, 19, 18, 18, 18, 20, 19, 19, 20, 19, 18, 18, 19, 19, 20, 19, 20, 20, 21,20, 19, 19};//最后一位：考生年龄:19

        double[] orange1 = {84, 90, 86, 78, 71, 67, 78, 89, 81, 80, 91, 81, 85, 76, 65, 68, 99, 99, 96, 88, 92, 91, 95, 65, 75, 74, 84, 74, 86, 95};
        double[] orange2 = {87, 88, 75, 80, 78, 67, 89, 64, 88, 77, 85, 72, 76, 85, 65, 75, 76, 99, 66, 98, 72, 71, 95, 86, 78, 88, 84, 84, 84, 96};
        double[] orange3 = {83, 77, 84, 85, 75, 64, 78, 69, 80, 80, 83, 87, 85, 65, 65, 68, 69, 96, 96, 93, 92, 81, 65, 95, 76, 82, 78, 74, 88, 96};

        double mazi1;//代表每个学生的总分
        double mazi2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            mazi1 =orange1[i] + orange2[i] + orange3[i];
//            mazi2= (mazi1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + mazi1);
//            System.out.println(name[i] + "的平均分为:" + mazi2);
//        }


        double hunzi1 = 0,hunzi2 = 0;
        double[] xiaoya = new double[30];
//        for (int i = 0; i < 30; i++) {
//            hunzi1=orange1[i] +orange2[i] + orange3[i];
//            hunzi2 = (hunzi1* 1.0) / 3;
//            xiaoya[i] = hunzi2;
//        }
//
//        for (int i = 0; i < xiaoya.length - 1; i++) {
//            for (int j = 0; j <xiaoya.length - i - 1; j++) {
//                if (xiaoya[j] <xiaoya[j + 1]) {
//                    double tep = xiaoya[j];
//                    xiaoya[j] =xiaoya[j + 1];
//                    xiaoya[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(xiaoya[i]);
//        }


        double lvjian1 = 0,lvjian2 = 0, lvjian3 = 0;//计算每门课的平均分
        double shengxian1 = 0,  shengxian2 = 0, shengxian3 = 0;//计算每门课标准差
        double shili1 = 0,shili2 = 0, shili3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i < orange1.length; i++) {
            he += orange1[i];
        }
        lvjian1 = (he * 1.0) / 30;
        System.out.println("农业设施及环境调控的班级平均分为:" +lvjian1);
        double Sum = 0;
        for (int i = 0; i < orange2.length; i++) {
            Sum += orange2[i];
        }
        lvjian2 = (Sum * 1.0) / 30;
        System.out.println("农业设施设计与建造的班级平均分为:" +lvjian2);
        double sum = 0;
        for (int i = 0; i < orange3.length; i++) {
            sum +=orange3[i];
        }
        lvjian3 = (sum * 1.0) / 30;
        System.out.println("园艺植物设施栽培学的班级平均分为:" + lvjian3);



        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i < orange1.length; i++) {
            c1 += (orange1[i] - lvjian1) * (orange1[i] -lvjian1);
        }
        shengxian1 = Math.sqrt(c1*1.0/30);
        System.out.println("农业设施及环境调控的班级标准差为:" +shengxian1);
        for (int i = 0; i <orange2.length; i++) {
            c2 += (orange2[i] - lvjian2) * (orange2[i] -lvjian2);
        }
        shengxian2 = Math.sqrt(c2*1.0/30);
        System.out.println("农业设施设计与建造的班级标准差为:" +shengxian2);

        for (int i = 0; i <orange3.length; i++) {
            c3 += (orange3[i] - lvjian3) * (orange3[i] - lvjian3);
        }
        shengxian3 = Math.sqrt(c3*1.0/30);
        System.out.println("园艺植物设施栽培学的标准差为:" +shengxian3);
////////
//        Arrays.sort(orange1);
//        Arrays.sort(orange2);
//        Arrays.sort(orange3);
//        shili1 = (orange1[15] + orange1[14]) * 1.0 / 2;
//        shili2 = (orange2[15] +orange2[14]) * 1.0 / 2;
//        shili3 = (orange3[15] +orange3[14]) * 1.0 / 2;
//        System.out.println("农业设施及环境调控的中位数为:" +  shili1);
//        System.out.println("农业设施设计与制造的中位数为:" +  shili2);
//        System.out.println("园艺植物设施栽培学的中位数为:" +  shili3);




    }
}
